package view;

import model.Topic;
import processing.core.*;

public class TopicOverview extends PApplet{
	int width = 1000;
	int height = 800; 
	boolean update = true; 
	boolean grow = false; 
	Topic group ; 
	public void setup(){	
		initTopics(); 
		size(width, height, P2D); 
		Topic.setFontandColor(this); 
		textMode(SCREEN);
		textAlign(CENTER); 
		//smooth(); 
	}
	public void initTopics(){
		group = Topic.Root("Topics in Health", width, height); 
		Topic t1 = group.addMember("Population", 160, 7);
		Topic t2 = group.addMember("Natality", 175, 5);
		Topic t3 = group.addMember("Mortality", 170, 5);
		Topic t4 = group.addMember("Measure of Health", 260, 10);
		Topic t5 = group.addMember("Abulatory Care", 260, this.random(3)); 
		Topic t6 = group.addMember("Inpatient Care", 240, 20);
		Topic t7 = group.addMember("Health Care Resources", 280, 3); 
		Topic t7_1 = t7.addMember("Personnel", 160, 2); 
		Topic t7_2 = t7.addMember("Facilities", 160); 
		Topic t8 = group.addMember("Health Care Cost", 300, 20);
		Topic t8_1 = t8.addMember("Expenditures", 150, 10);
		Topic t8_2 = t8.addMember("Programs", 160, 10); 
	}
	public void draw(){
		background(255); 
		noStroke(); 
		if (grow) group.grow(); 
		group.show(this);
		//group.showLabel(this); 
		if (update) group.update(); 
	}
	public void mousePressed(){
	
		
	}
	public void keyPressed(){
		if (key=='a'){
			update=!update; 
			print("turn "); 
			if (update) print("on "); 
			else print("off "); 
			println("update"); 
		}
		if (key=='b'){
			grow=!grow; 
			print("turn "); 
			if (update) print("on "); 
			else print("off "); 
			println("grow"); 
		}
		if (key=='c'){
			println("save a picture"); 
			saveFrame("pic/pic-####.png"); 
		}
		if (key=='d'){
			
		}	
	}

}

